home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Symantec Versions / C07 QuickTime Movies / P03 Select Movie / SelectMovie.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-31  |  2.6 KB  |  110 lines  |  [TEXT/KAHL]

  1. //____________________________________________________________
  2. //    SelectMovie.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Movies.h>
  13.  
  14.  
  15. //____________________________________________________________
  16.  
  17. void  InitializeAllToolboxes( void );
  18.  
  19.  
  20. //____________________________________________________________
  21.  
  22. #define      rMovieWindow        128
  23.  
  24.  
  25. //____________________________________________________________
  26.  
  27. void  main( void )
  28.    OSErr              theError;
  29.    FSSpec             theFSSpec;
  30.    short              theFileRefNum;
  31.    Movie              theMovie;
  32.    short              theMovieResID = 0;   
  33.    Str255             theMovieResName;
  34.    Boolean            wasAltered;
  35.    WindowPtr          theWindow;
  36.    Rect               theMovieBox;
  37.    SFTypeList         typeList = { MovieFileType, 0, 0, 0 };
  38.    StandardFileReply  theReply;
  39.  
  40.    InitializeAllToolboxes();
  41.    
  42.    StandardGetFilePreview( nil, 1, typeList, &theReply );
  43.  
  44.    if ( theReply.sfGood == true )
  45.    {          
  46.       theError = OpenMovieFile( &theReply.sfFile, &theFileRefNum, fsRdPerm );
  47.       theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
  48.                                     theMovieResName, newMovieActive, &wasAltered );
  49.       CloseMovieFile( theFileRefNum );
  50.    }
  51.    else
  52.    {
  53.       ExitToShell();
  54.    }
  55.    
  56.    theWindow = GetNewCWindow( rMovieWindow, nil, (WindowPtr)-1L );   
  57.  
  58.    SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );   
  59.  
  60.    GetMovieBox( theMovie, &theMovieBox );
  61.    OffsetRect( &theMovieBox, -theMovieBox.left, -theMovieBox.top );
  62.    SetMovieBox( theMovie, &theMovieBox );
  63.  
  64.    SizeWindow( theWindow, theMovieBox.right, theMovieBox.bottom, true );  
  65.    ShowWindow( theWindow);
  66.  
  67.    GoToBeginningOfMovie( theMovie );
  68.  
  69.    StartMovie( theMovie );
  70.  
  71.    do
  72.    {
  73.       MoviesTask(theMovie, 0);
  74.    }
  75.    while ( IsMovieDone( theMovie ) == false );
  76.    
  77.    DisposeMovie( theMovie );
  78.    DisposeWindow( theWindow );
  79. }
  80.  
  81.  
  82. //____________________________________________________________
  83.  
  84. void  InitializeAllToolboxes( void )
  85. {
  86.    OSErr  theError;
  87.    long   theResult;
  88.  
  89.    InitGraf( &qd.thePort );
  90.    InitFonts();
  91.    InitWindows();
  92.    InitMenus();
  93.    TEInit();
  94.    InitDialogs( 0L );
  95.    FlushEvents( everyEvent, 0 );
  96.    InitCursor();
  97.  
  98.    theError = Gestalt( gestaltQuickTime, &theResult );
  99.    if ( theError != noErr )
  100.       ExitToShell();
  101.                                                  
  102.    theError = EnterMovies();  
  103.    if ( theError != noErr )
  104.       ExitToShell(); 
  105. }
  106.  
  107.  
  108.  
  109.